<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/common.jsp"%>
<link rel="stylesheet" href="${ctx}/page/include/css/topicItem.css" />
<link rel="stylesheet" href="${ctx}/page/include/css/adviertisement.css" />

<title>首页</title>
</head>
<body>
		<%@ include file="../common/header.jsp"%>
		<div class="container">
			<div class="row">
				<div class="col-md-9">
					<div class="panel panel-default">
						<div class="panel-heading">
							<span class="glyphicon glyphicon-list-alt"></span>&nbsp<span style="color: #000">发现</span>
							<div class="pull-right">
								<a class="<c:if test='${searchType ne 0}'>topicSelect</c:if>" href="${ctx}">全部</a>
								<a class="<c:if test='${searchType ne 1}'>topicSelect</c:if>" href="${ctx}?recommend=1">推荐</a>
								<a class="<c:if test='${searchType ne 2}'>topicSelect</c:if>" href="${ctx}?sortParam=replyCounts&sortType=DESC">热门</a>
								<a class="<c:if test='${searchType ne 3}'>topicSelect</c:if>" href="${ctx}?sortParam=replyCounts&sortType=ASC">等待回复</a>
							</div>
						</div>

						<div class="panel-body  paginate-bot">
							<c:forEach items="${topicPage.list}" var="topic">
								<div class="media">
									<div class="media-left">
										<img onerror="this.src='${ctx}/static/imgs/avatar.jpg'" src="${topic.member.avatar}" class="avatar">
									</div>
									<div class="media-body">
										<a class="title" href="${ctx}/topic/${topic.id}"><p class="media-heading">${topic.title}</p></a>
										<c:if test="${topic.recommend eq 1}">
											<span class="label label-success">推荐</span>
											<span class="tInfo">•</span>
										</c:if>
										<a class="section" href="${ctx}/topic/sectionTopics?sectionId=${topic.section.id}&sectionName=${topic.section.name}">${topic.section.name}</a>
										<span class="hidden-sm hidden-xs tInfo">${topic.member.name}</span> 
										<span class="hidden-sm hidden-xs tInfo">•</span> 
										<span class="hidden-sm hidden-xs tInfo">${topic.replyCounts}条回复</span> 
										<span class="hidden-sm hidden-xs tInfo">•</span> 
										<span class="hidden-sm hidden-xs tInfo">${topic.viewCounts}次浏览</span> 
										<span class="tInfo">•</span> 
										<span class="tInfo">${topic.formatDate(topic.createTime)}</span>
									</div>
								</div>
								<div class="divide"></div>
							</c:forEach>
							<c:if test="${topicPage.totalCount gt topicPage.pageSize}">
							 <ul class="pagination pagination-sm">
								<c:if test="${topicPage.firstPage eq false}">
									<c:choose>
										<c:when test="${searchType eq 0}">
											<li><a href="${ctx}?pageNo=1&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;&lt;</a></li>
											<li><a href="${ctx}?pageNo=${topicPage.prePage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;</a></li>
										</c:when>
										<c:when test="${searchType eq 1}">
											<li><a href="${ctx}?recommend=1&pageNo=1&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;&lt;</a></li>
											<li><a href="${ctx}?recommend=1&pageNo=${topicPage.prePage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;</a></li>
										</c:when>
										<c:when test="${searchType eq 2}">
											<li><a href="${ctx}?sortParam=replyCounts&sortType=DESC&pageNo=1&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;&lt;</a></li>
											<li><a href="${ctx}?sortParam=replyCounts&sortType=DESC&pageNo=${topicPage.prePage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;</a></li>
										</c:when>
										<c:when test="${searchType eq 3}">
											<li><a href="${ctx}?sortParam=replyCounts&sortType=ASC&pageNo=1&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;&lt;</a></li>
											<li><a href="${ctx}?sortParam=replyCounts&sortType=ASC&pageNo=${topicPage.prePage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&lt;</a></li>
										</c:when>
									</c:choose>
								</c:if>
								<c:forEach items="${pages}" var="page">
									<c:choose>
										<c:when test="${page eq topicPage.pageNo}">
											<li class="active"><a class="disabled">${page}</a></li>
										</c:when>
										<c:otherwise>
											<c:if test="${searchType eq 0}">
												<li><a href="${ctx}?pageNo=${page}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">${page}</a></li>
											</c:if>
											<c:if test="${searchType eq 1}">
												<li><a href="${ctx}?recommend=1&pageNo=${page}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">${page}</a></li>
											</c:if>
											<c:if test="${searchType eq 2}">
												<li><a href="${ctx}?sortParam=replyCounts&sortType=DESC&pageNo=${page}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">${page}</a></li>
											</c:if>
											<c:if test="${searchType eq 3}">
												<li><a href="${ctx}?sortParam=replyCounts&sortType=ASC&pageNo=${page}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">${page}</a></li>
											</c:if>
										</c:otherwise>
									</c:choose>
								</c:forEach>
								<c:if test="${topicPage.lastPage eq false}">
									<c:choose>
										<c:when test="${searchType eq 0}">
											<li><a href="${ctx}?pageNo=${topicPage.nextPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;</a></li>
											<li><a href="${ctx}?pageNo=${topicPage.totalPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;&gt;</a></li>
										</c:when>
										<c:when test="${searchType eq 1}">
											<li><a href="${ctx}?recommend=1&pageNo=${topicPage.nextPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;</a></li>
											<li><a href="${ctx}?recommend=1&pageNo=${topicPage.totalPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;&gt;</a></li>
										</c:when>
										<c:when test="${searchType eq 2}">
											<li><a href="${ctx}?sortParam=replyCounts&sortType=DESC&pageNo=${topicPage.nextPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;</a></li>
											<li><a href="${ctx}?sortParam=replyCounts&sortType=DESC&pageNo=${topicPage.totalPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;&gt;</a></li>
										</c:when>
										<c:when test="${searchType eq 3}">
											<li><a href="${ctx}?sortParam=replyCounts&sortType=ASC&pageNo=${topicPage.nextPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;</a></li>
											<li><a href="${ctx}?sortParam=replyCounts&sortType=ASC&pageNo=${topicPage.totalPage}&pageSize=${topicPage.pageSize}&sectionId=${sectionId}">&gt;&gt;</a></li>
										</c:when>
									</c:choose>
								</c:if>
							 </ul>
							</c:if>
						</div>
					</div>
				</div>
				<div class="col-md-3 hidden-sm hidden-xs">
					<c:if test="${member eq null}">
						<%@ include file="../include/welcome.jsp"%>
					</c:if>
					<c:if test="${member ne null}">
						<%@ include file="../include/memberInfo.jsp"%>
					</c:if>
					<c:forEach items="${ads}" var="ad">
						<div class="panel panel-default">
							<div class="panel-heading">${ad.title}</div>
							<div class=" panel-body">
								<a target="_blank" href="${ad.url}" class="thumbnail">
									<img alt="广告" src="${ad.image}">
								</a>
								<div class="text-center">
									<small>${ad.description}</small>
								</div>
							</div>
						</div>
					</c:forEach>
				</div>
			</div>
		</div>

	<%@ include file="../common/footer.jsp"%>
</body>
</html>